package com.ymatou.query.trading.api.testcase;

import java.util.ArrayList;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.query.trading.api.parameter.GetOrderListByReceiverBean;
import com.ymatou.query.trading.api.service.GetOrderListByReceiverCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.common.entitie.OrderInfoForQuery;
import com.ymttest.utils.constant.ECode;

/**
 * 获取指定用户名下及收货人的和手机的所有订单列表(暂时用于码头app) FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_GetOrderListByReceiver {

	private static GetOrderListByReceiverBean getorderlistbyreceiverbean;
	private static GetOrderListByReceiverCall getorderlistbyreceivercall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取指定用户名下及收货人的和手机的所有订单列表(暂时用于码头app)");
	}

	@Before
	public void caseUp() {

		getorderlistbyreceiverbean = new GetOrderListByReceiverBean();
		getorderlistbyreceivercall = new GetOrderListByReceiverCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getorderlistbyreceivercall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetOrderListByReceiver_001() {
		Logger.start(true,"获取指定用户名下及收货人的和手机的所有订单列表(暂时用于码头app)成功");
		try {
			// TODO 这个case很慢 需要查看具体原因
			// 参数
			getorderlistbyreceiverbean.setBuyerId(1113);
			String PhoneNum = "13100000001";
			getorderlistbyreceiverbean.setPhoneNum(PhoneNum);
			String ReceiverName = "张三";
			getorderlistbyreceiverbean.setReceiverName("张三");
			// 发送请求
			getorderlistbyreceivercall.setData(getorderlistbyreceiverbean);
			getorderlistbyreceivercall.callService();
			Logger.comment("getorderlistbyreceivercall send:" + getorderlistbyreceivercall.getEntityString());
			// 返回数据太多不写xml文件
			// Logger.comment("getorderlistbyreceivercall response:"+getorderlistbyreceivercall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, getorderlistbyreceivercall.getCode(), "验证Code");
			// Logger.verifyEquals(ErrorCode.SUCCESSMSG,
			// getorderlistbyreceivercall.getMsg(), "验证Msg");
			ArrayList<OrderInfoForQuery> orderlist = getorderlistbyreceivercall.getOrderInfoList();
			Logger.verifyEquals(true, orderlist.size() >= 0, "验证查询结果长度:" + orderlist.size());
			for (OrderInfoForQuery orderInfo : orderlist) {
				Logger.verifyEquals(ReceiverName, orderInfo.ReceivePerson, "验证收货人");
				Logger.verifyEquals(PhoneNum, orderInfo.Phone, "验证收件人手机号");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}